<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<jsp:include page="../frame/header.jsp"></jsp:include>

<title>论坛积分规则</title>

<style>
.pagination .active a {
	/*background-color: #CC0041;
	color:white;*/
}
.table td {
	padding-top:4px;
	padding-bottom:4px;
}

.table td i{
	margin-top:2px;
}

</style>

</head>

<body>

	<div class="container-fluid">
		<div id="market" class="row-fluid">
			<div>
				<ul class="breadcrumb">
					<li><a href="#">会员管理</a> <span class="divider">/</span></li>
					<li><a href="#">论坛积分规则</a></li>
				</ul>
			</div>

			<div class="box">
				<div class="box-header well" data-original-title>
					<h2>
						<i class="icon-th"></i> 用户积分规则修改
					</h2>

					<div class="box-icon">
						<a href="#" class="btn btn-setting btn-round"><i
							class="icon-cog"></i></a> <a href="#"
							class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
						<a href="#" class="btn btn-close btn-round"><i
							class="icon-remove"></i></a>
					</div>
				</div>
				<div class="box-content">
					<form id="myform" class="form-horizontal" method="post"
						action="<c:url value="/admin/member/forumRule" />">

						<fieldset>
							<table id="rules" class="table table-striped table-bordered ">
								<thead>
									<tr>
										<th>规则编号</th>
										<th>规则名称</th>
										<th>加经验值</th>
										<th>是否启用</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${rules }" var="rule">
									<tr>
										<td>${rule.ruleType }</td>
										<td>${rule.ruleName }</td>
										<td><i class="icon-plus"></i>&nbsp;<input type="text" class="input-small" value="${rule.ruleValue }"></td>
										<td>
											<label class="radio inline">
												<input type="radio" name="disabled_${rule.ruleType }" value="0" <c:if test="${rule.disabled == 0 }">checked</c:if>> 启用
											</label>
											<label class="radio inline">
												<input type="radio" name="disabled_${rule.ruleType}" value="1" <c:if test="${rule.disabled == 1 }">checked</c:if>>禁用
											</label>
											
										</td>
									</tr>
									</c:forEach>
								</tbody>
							</table>
							
							<input type="hidden" name="ruleStr" id="ruleStr">
							
							<div class="form-actions">
								<button id="saveBtn" type="button" class="btn btn-primary">提交</button>
							</div>
						</fieldset>
					</form>
				</div>
			</div>
		</div>
		<!--/fluid-row-->

	</div>
	<!--/.fluid-container-->

	<jsp:include page="../frame/scripts.jsp"></jsp:include>
	<script type="text/javascript">
	
	$(document).ready(function(){

		//保存
		$('#saveBtn').click(function() {
			var infos = [];
			$("#rules tbody tr").each(function(i,item){
				if($(item) != null && $(item).length > 0){
					var info = new Object();
					
					info.ruleType = $(item).find("td:eq(0)").html();
					info.ruleValue = $(item).find("td:eq(2)").find("input").val();
					info.disabled = $(item).find("td:eq(3)").find("input:checked").val();
					infos.push(info);
				}
			})
			
			var str = JSON.stringify(infos);
			$("#ruleStr").val(str);
			$("#myform").submit();
		})
		
		
	});
	
	
	</script>
</body>
</html>
